package com.ruoyi.mall.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallTimeBanner;
import com.ruoyi.mall.service.IMallTimeBannerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抢购轮播图Controller
 *
 * @author ruoyi
 * @date 2022-02-24
 */
@RestController
@RequestMapping("/mall/mallTimeBanner")
public class MallTimeBannerController extends BaseController
{
    @Autowired
    private IMallTimeBannerService mallTimeBannerService;

    /**
     * 查询抢购轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeBanner:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallTimeBanner mallTimeBanner)
    {
        startPage();
        List<MallTimeBanner> list = mallTimeBannerService.selectMallTimeBannerList(mallTimeBanner);
        return getDataTable(list);
    }

    /**
     * 导出抢购轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeBanner:export')")
    @Log(title = "抢购轮播图", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallTimeBanner mallTimeBanner)
    {
        List<MallTimeBanner> list = mallTimeBannerService.selectMallTimeBannerList(mallTimeBanner);
        ExcelUtil<MallTimeBanner> util = new ExcelUtil<MallTimeBanner>(MallTimeBanner.class);
        return util.exportExcel(list, "抢购轮播图数据");
    }

    /**
     * 获取抢购轮播图详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeBanner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallTimeBannerService.selectMallTimeBannerById(id));
    }

    /**
     * 新增抢购轮播图
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeBanner:add')")
    @Log(title = "抢购轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallTimeBanner mallTimeBanner)
    {
        return toAjax(mallTimeBannerService.insertMallTimeBanner(mallTimeBanner));
    }

    /**
     * 修改抢购轮播图
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeBanner:edit')")
    @Log(title = "抢购轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallTimeBanner mallTimeBanner)
    {
        return toAjax(mallTimeBannerService.updateMallTimeBanner(mallTimeBanner));
    }

    /**
     * 删除抢购轮播图
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeBanner:remove')")
    @Log(title = "抢购轮播图", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallTimeBannerService.deleteMallTimeBannerByIds(ids));
    }
}
